import Layout from './components/layout.vue';
import demoRoutes from './demoRoutes';

export default [
  {
    path: '/docs',
    // component: () => { console.log(arguments, Vue.component('RouterView')); return Vue.component('RouterView'); },
    component: Layout,
    props: route => {
      try {
        const name = route.path.split('/components/')[1].split('/')[0];
        return { name, showDemo: true };
      } catch (e) {
        const name = route.path.split('/docs/')[1].split('/')[0];
        return { name, showApi: true };
      }
    },
    redirect: '/docs/introduce',
    children: [
      {
        path: 'introduce',
        component: () => import('../docs/introduce.md'),
      },
      {
        path: 'use-with-vue-cli',
        component: () => import('../docs/use-with-vue-cli.md'),
      },
      {
        path: 'faq',
        component: () => import('../docs/faq.md'),
      },
      {
        path: 'download',
        component: () => import('../docs/download.md'),
      },
      {
        path: 'changelog',
        component: () => import('../CHANGELOG.md'),
      },
      {
        path: 'customize-theme',
        component: () => import('../docs/customize-theme.md'),
      },
      {
        path: 'getting-started',
        component: () => import('../docs/getting-started.md'),
      },
      {
        path: 'components',
        // component: () => import('./components/viewRouter'),
        component: { template: '<router-view />' },
        redirect: `/docs/components/${demoRoutes[0].path}`,
        children: demoRoutes,
      },
    ],
  },
  { path: '/*', redirect: '/docs/introduce/' },
];
